home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
QRZ! Ham Radio 4
/
QRZ Ham Radio Callsign Database - Volume 4.iso
/
unix
/
src
/
pick.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-11-01
|
875b
|
67 lines
#include <stdio.h>
#include <string.h>
#include "cb.h"
main(argc,argv)
int argc;
char *argv[];
{
FILE *fp;
char str[1024];
char buf[16];
char *p;
char *d;
int recs;
int inds;
int modulus;
if (!argv[1])
{
printf("Usage: %s dbase_name n-modulus\n",argv[0]);
exit(1);
}
if ((fp=fopen(argv[1],"r")) == NULL)
{
printf("Error opening file %s.\n",argv[1]);
exit(1);
}
sscanf(argv[2],"%d",&modulus);
if (modulus < 1)
{
printf("Invalid n-modulus\n");
exit(1);
}
recs = 0;
inds = 0;
printf("\n");
while (!feof(fp))
{
memset(str,0,sizeof(str));
memset(buf,0,sizeof(buf));
fgets(str,sizeof(str),fp);
if (!strlen(str))
break;
if (!(recs%modulus))
{
p = str;
d = buf;
while(*p != ',')
*d++ = *p++;
printf ("%s\n",buf);
inds++;
}
recs++;
}
fclose(fp);
printf("\n- %d calls picked -\n",inds);
exit(0);
}